package com.book.config;

import com.book.exception.GlobalException;
import com.book.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler extends RuntimeException{


    @ExceptionHandler(GlobalException.class)
    @ResponseBody
    public R error(GlobalException exception){
        return R.error(exception.getMessage());
    }

}
